feat!: ship types, complete the models, and add production, flight and combat - #34
Merged
Merged
Conversation
rolljee
force-pushed
the
feat/v4-types-fleets-research
branch
from
July 25, 2026 07:04
dc7257a to
bb5eeec
Compare
…d combat
Rounds out the library from "mine costs" to most of the maths a calculator
needs, and fixes the naming and data problems that had accumulated.
Models
- Buildings goes from 5 to 19 entries: storages, facilities and moon buildings.
- New Research model with the 16 technologies, Astrophysics rounding included.
- Every entry carries `names: { en, fr }` and `ogameId`, the id the game uses.
- `base` fields are named after what they are: `energyCost` (paid to build),
`energyConsumption` (consumed once built) and `deuteriumConsumption` replace
the `energy`/`consumption` pair that meant different things per building.
- `deutCost` held half the real fuel consumption on all 15 ships; corrected and
renamed `fuelConsumption`. Ships also gained `drive` and `driveUpgrades`.
- models.test.js asserts the invariants every entry must hold, so a future
entry that is incomplete or inconsistent fails CI.
Calculators
- The five mine and plant calculators no longer reimplement
`base * factor ** (level - 1)`; they share cost.js and info.js, and all
return the same seven fields. Behaviour is unchanged, verified against the
previous expectations.
- They take the whole entry instead of its `base`, like everything else, and
throw a message pointing at the fix when handed a `base`.
- New: getBuildingCost, getBuildTime, getStorage, getPlanetProduction,
getProductionBonus, getResearchCost, getResearchTime.
Fleets
- getDistance, getShipSpeed, getFleetSpeed, getActiveDrive, getFlightTime,
getFuelConsumption, getTrip.
- simulateCombat: six rounds, rapid fire, shield bounce and explosion odds,
seedable so a battle can be replayed and averaged.
Types
- TypeScript declarations generated from the JSDoc into types/, wired through
the exports map and built by prepack. Verified against a strict TS consumer.
Also
- The exports map only allowed the package root, so the subpath import the
README documented never worked. Named subpaths added.
- README and CONTRIBUTING rewritten for the new surface, and MIGRATION.md added.
- infocompte reads its language from the report, accepts custom labels, throws
readable errors, and returns numbers for mine levels.
BREAKING CHANGE: mine and plant calculators now take `Buildings[id]` rather
than `Buildings[id].base`, and return `energyCost`/`energyConsumption`/
`deuteriumConsumption` instead of `energy`/`consumption`.
BREAKING CHANGE: model fields renamed — `entry.name` to `entry.names.fr`,
`base.deutrium` to `base.deuterium`, `base.energy` to `base.energyConsumption`
or `base.energyCost`, `base.consumption` to `base.deuteriumConsumption`,
`fret` to `cargo`, `cost.deut` to `cost.deuterium`, and `deutCost` to
`fuelConsumption` with corrected values (they were half the in-game figure).
BREAKING CHANGE: parseInfoCompteData returns planet mine levels as numbers
instead of strings, and getDebris returns an extra `deuterium` key.
See MIGRATION.md for the full upgrade path.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
rolljee
force-pushed
the
feat/v4-types-fleets-research
branch
from
July 25, 2026 07:18
bb5eeec to
af69541
Compare
|
🎉 This PR is included in version 4.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Takes the library from "mine cost calculators" to most of the maths a real OGame tool needs, and fixes the naming and data problems that had built up along the way.
This is a major. MIGRATION.md has the full upgrade path; every rename throws an error that points at its fix, so a test run finds the call sites for you.
The five gaps this closes
types/, wired through theexportsmap, built byprepack. Verified against a strict TS consumer,ogamejs/typesincluded.metal/crystal/deut/solar-plant/fusion-reactorsharecost.jsandinfo.js. Same numbers, checked against the previous expectations.Buildings[id], neverBuildings[id].base.base.energywas ambiguousenergyCost(paid to build),energyConsumption(consumed once built) anddeuteriumConsumption. TheenergyIsCostworkaround is gone.Models
Buildings: 5 → 19 entries (storages, facilities, moon buildings).Researchmodel, 16 technologies, with Astrophysics' 1.75 factor and its rounding to the hundred —getResearchCost(Research[124], 5)gives the exact in-game37 600 / 75 100 / 37 600.names: { en, fr }andogameIdon every entry.driveanddriveUpgrades.One data correction worth flagging:
deutCostheld exactly half the in-game fuel consumption on all 15 ships (light fighter 10 vs 20, cruiser 150 vs 300 — the factor of 2 was systematic). It is nowfuelConsumptionwith the real values. If anything downstream compensated by doubling, that has to come out.New API
Plus
getBuildingCost,getBuildTime,getStorage,getProductionBonus,getResearchTime,getDistance,getShipSpeed,getFleetSpeed,getActiveDrive,getFlightTime,getFuelConsumption.Also fixed
exportsmap only allowed the package root, soimport Building from 'ogamejs/src/buildings/index.js'— which the 3.x README documented — never actually worked. Named subpaths added and verified by installing the tarball into a scratch project.parseInfoCompteDatareads its language from the report header, accepts customlabelsfor unsupported languages, throws readable errors instead of a bareTypeError, and returns planet mine levels as numbers (they were strings, whiletemperaturein the same object was already a number).defensesto themissilescategory, whichATTRIBUTES.CATEGORIES.MISSILEhad always been waiting for.Tests
28 → 315. Expected values are derived by hand from the formulas rather than copied out of the implementation.
src/models/models.test.jsasserts the invariants every model entry must hold — a completebase, a known category and drive, rapid-fire targets that resolve,structure === cost.metal + cost.crystal, no duplicateogameId, both translations present. Adding an entry that breaks one of those fails CI.CI runs lint, tests, and a new
typesjob on every PR.What I deliberately did not do
Verification
Also verified end to end by packing the tarball, installing it into a fresh project, and compiling a strict TypeScript consumer against it.
🤖 Generated with Claude Code